<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

/**
 * Description of commoncall
 * 
 * @author Joydeb Choudhury (mcajoydeb@gmail.com)
 */
class Commoncall extends CI_Model {

    //put your code here

    function __construct() {
        parent::__construct();
        log_message('debug', 'Model Initialized');
    }

//--Check Admin LogIn --Subha--//    
    function check_admin_login() {
        $userdata = $this->session->userdata('sess_admin_user');
        if (!$userdata) {
            redirect('admin/login');
        }
    }

//--Check MEMBER LogIn --Subha--//    
    function check_member_login() {
        $userdata = $this->session->userdata('mem_id');
        if (!$userdata) {
            redirect('member/login');
        }
    }

//--Subha (Get Recent News with parameter no of News )--//    
    function get_recent_news($no) {
        if ($no) {
            $sql = "Select * from News order by id desc limit $no";
            return $this->db->query($sql)->result();
        }
    }

//--Subha (Get Recent News with parameter no of News )--//    
    function get_recent_reviews($no) {
        if ($no) {
            $sql = "Select * from Reviews where status=51 order by id desc limit $no ";
            return $this->db->query($sql)->result();
        }
    }

//--REVIEW RATING (Subha)--------//
    function review_ratting($model, $feature) {
        $experience = '0';
        $rate = 0;
        $sql = "SELECT $feature,COUNT(*) as 'no' FROM reviews WHERE model = $model GROUP BY $feature";
        $query = $this->db->query($sql);
        $result = $query->result();
        

    }

        function send_mail($email = NULL, $subject = NULL, $body = NULL) {

        $this->email->clear();
        //--Email Config
        $email_config['protocol'] = 'mail';
        $email_config['wordwrap'] = FALSE;
        $email_config['mailtype'] = 'html';
        $email_config['charset'] = 'utf-8';
        $email_config['crlf'] = "\r\n";
        $email_config['newline'] = "\r\n";
        $this->email->initialize($email_config);

        $this->email->to($email);
        $this->email->from($this->settings_model->get_setting('default_email'), $this->settings_model->get_setting('webtitle'));
        $this->email->subject($subject);
        $this->email->message($body);
        $this->email->send();
    }

}

?>